<template>
  <div class="video_tab_wrap">
    <el-table border stripe :data="videoList">
      <el-table-column label="视频名称" prop="Vname"></el-table-column>
      <el-table-column label="绑定课程" prop="Vstate"></el-table-column>
      <el-table-column label="视频时长" prop="Vtime"></el-table-column>
      <el-table-column label="发布日期">
        <template slot-scope="scope">
          <div>{{ new Date(scope.row.createAt).toLocaleString() }}</div>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <div>
            <el-link type="primary" @click="toEdit(scope.row)">编辑</el-link>
            <el-link type="danger" @click="delVideo(scope.row.ID)"
              >删除</el-link
            >
          </div>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      background
      layout="prev,pager,next"
      :total="total"
      :page-size="pageSize"
      @current-change="pageChange"
    >
    </el-pagination>
  </div>
</template>
<script>
import { _delVideo } from '@/api/video'
export default {
  props: {
    videoList: {
      type: Array,
      default: []
    },
    total: {
      type: Number
    },
    pageSize: {
      type: Number
    }
  },
  methods: {
    toEdit (row) {
      //去编辑
      this.$bus.$emit('sendvideo', row)
    },
    async delVideo (ID) {
      //删除视频
      var res = await _delVideo(ID)
      console.log(res)
      if (res.data.success) {
        this.$message.success('删除视频')
        this.$parent.getList()
      }
    },
    pageChange (val) {
      //分页
      //val 当前页码
      this.$parent.pageStart = val
      this.$parent.getList()
    }
  }
}
</script>
<style lang="less" scoped></style>
